package com.example.springboot.service;

import com.example.springboot.Dao.SysUserReposity;
import com.example.springboot.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

public class CustomerUserService implements UserDetailsService {

    @Autowired
    SysUserReposity sysUserReposity;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        SysUser user = sysUserReposity.findByUsername(username);
        if (user == null){
            System.out.println("该用户不存在");
            throw new UsernameNotFoundException("该用户不存在");
        }
        System.out.println("username:"+user.getUsername()+";password:"+user.getPassword());
        return user;
    }
}
